//
//  ZYLSearchBaseModel.m
//  Cartoon
//
//  Created by dllo on 15/7/14.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import "ZYLSearchResultModel.h"
#import "AFNetworkHandler.h"
@implementation ZYLSearchResultModel
- (void)dealloc
{
    [_searchcomics_count release];
    [_searchcover_image_url release];
    [_searchdescription release];
    [_searchid release];
    [_searchtitle release];
    [_searchuser_id release];
    [super dealloc];
    
}
- (instancetype)initWithDic:(NSDictionary *)dic
{
    self = [super init];
    if (self) {
        [self setValuesForKeysWithDictionary:dic];
        self.searchuser_id = dic[@"user"][@"id"];
        self.searchnickname = dic[@"user"][@"nickname"];
    }
    return self;
}
- (void)setValue:(id)value forUndefinedKey:(NSString *)key
{
}
- (id)valueForUndefinedKey:(NSString *)key
{
    return nil;
}
- (void)setValue:(id)value forKey:(NSString *)key
{
    [super setValue:value forKey:[NSString stringWithFormat:@"search%@", key]];
}


#pragma mark - 搜索结果
+ (void)SearchResultWithURLKeyword:(NSString *)keyword block:(void (^)(NSMutableArray *array))block
{
    NSString *str = [NSString stringWithFormat:@"http://api.kuaikanmanhua.com/v1/topics/search?keyword=%@&offset=0&limit=20", keyword];
    [AFNetworkHandler GETwithAFNByURL:str completion:^(id result) {
        NSArray *tempArr = result[@"data"][@"topics"];
        NSMutableArray *arr = [NSMutableArray array];
        for (NSDictionary *dic in tempArr) {
            ZYLSearchResultModel *model = [[ZYLSearchResultModel alloc] initWithDic:dic];
            [arr addObject:model];
            [model release];
        }
        block(arr);
    }];
}




@end
